import java.util.Comparator;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;

public class Test02TreeSet {
    public static void main(String[] args) {
        Comparator<Student> comparator = new Comparator<Student>() {
            @Override
            public int compare(Student o1, Student o2) {
                int num = -1;
                num = o1.getAge() - o2.getAge();
                if(num == 0){
                    num = -o1.getName().compareTo(o2.getName());
                }
                return num;
                // throw new UnsupportedOperationException("Unimplemented method 'compare'");
            }
        };

        Set<Student> set = new TreeSet<>(comparator);
        Student s1 = new Student("zs",21);
        Student s2 = new Student("zs",19);
        Student s3 = new Student("ls",21);
        Student s4 = new Student("ww",20);
        set.add(s1);
        set.add(s2);
        set.add(s3);
        set.add(s4);
        System.out.println(set);
    }
}
